//
//  offlineController.m
//  FreeTrip
//
//  Created by 邓芮 on 15/11/27.
//  Copyright © 2015年 邓芮. All rights reserved.
//

#import "offlineController.h"

@interface offlineController ()

@end

@implementation offlineController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.navigationItem.title = @"离线说明";
//    UILabel *title = [[UILabel alloc]initWithFrame:CGRectMake(0, 94 *KScreenWidth / 414, KScreenWidth, 40 * KScreenWidth / 414)];
//    title.textAlignment = NSTextAlignmentCenter;
//    title.font = [UIFont systemFontOfSize:22 * KScreenWidth/ 414 weight:2];
//    title.text = @"离线使用说明";
//    title.backgroundColor = [UIColor redColor];
//    [self.view addSubview:title];
    NSString *text = @"FreeTrip支持“攻略”部分的文本离线浏览，驴友日志方面需要更新，暂不支持。只要曾经打开过某个目的地，该目的地文字部分会自动保存，即便在飞行模式下也可正常查看。\n由于图片无法自动离线，但是如果你曾经点击查看过这张图片，它就可以在无网络时查看。所以，你可以对有帮助的图片提前点击缓存下来。“攻略”部分的“相关内容”模块也无法自动离线，同上，它也需要提前点击过才能缓存下来。\nFreeTrip的”清空缓存“是指清空App中浏览过的图片文件和文本离线缓存，如果需要在旅行中查看详细信息，万不可点击此项，切记切记。";
    CGFloat x = 20 *KScreenWidth/ 414;
    CGFloat width = KScreenWidth - 2 * x;
    CGFloat y = 94 * KScreenWidth / 414;
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(x, y, width, 0)];
    label.text = @"alignment : NSTextAlignmentJustified";
    label.text = @"firstLineHeadIndent : 36";
    label.text = @"lineHeigtMultiple : 1.0";
    label.font = [UIFont systemFontOfSize:20 * KScreenWidth / 414];
    // 创建实例
    NSMutableAttributedString *attStr = [[NSMutableAttributedString alloc]initWithString:text];
    NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc]init];
    style.alignment = NSTextAlignmentJustified;
    style.firstLineHeadIndent = 36;
    style.lineHeightMultiple = 1.0;
    style.paragraphSpacing = 20;
    // 设置行间距
    [style setLineSpacing:6 * KScreenWidth / 414];
    label.numberOfLines = 0;
    // range 适用于哪一段字体
    [attStr addAttribute:NSParagraphStyleAttributeName value:style range:NSMakeRange(0, text.length)];
    
    CGRect bounds = [text boundingRectWithSize:CGSizeMake(width, 10000) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:label.font,NSParagraphStyleAttributeName:style} context:nil];
    label.attributedText = attStr;
    label.frame = CGRectMake(x, y, width, bounds.size.height);
    
//    label.backgroundColor = [UIColor cyanColor];
    
    self.view.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:label];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
